package mahmoud.sigir.test;

import java.util.ArrayList;

import mahmoud.sigir.search.QueryGen;
import mahmoud.utils.MinHeap;
import mahmoud.utils.Result;
import mahmoud.utils.WieghtedTerm;

public class Evaluator 
{
	public boolean dumpToFile()
	{
		return false;
	}
	public boolean evaluate()
	{
//		QueryGen QG = new QueryGen("/media/Data/dDocuments/Code/builtIndexes/TREC-FT");
		QueryGen QG = new QueryGen("d:/dDocuments/Code/builtIndexes/TREC-FT");
		ArrayList<WieghtedTerm> iQuery = new ArrayList<WieghtedTerm>();
		iQuery.add(new WieghtedTerm("quant", 1));
		iQuery.add(new WieghtedTerm("analyst", 1));
		QG.GTS.openSearcher();
		
		long start = System.currentTimeMillis();
		MinHeap<Result> result1  = QG.GTS.luceneSearch(iQuery);
		long end = System.currentTimeMillis();
		System.out.println("Ground truth search Took: "+(end-start)/1000.0+" Seconds.");
		
		start = System.currentTimeMillis();
		ArrayList<WieghtedTerm> rQuery  = QG.constructDenseQuery(iQuery,QueryGen.TrecFile);
		end = System.currentTimeMillis();
		System.out.println("construction Took: "+(end-start)/1000.0+" Seconds.");
		System.out.println("Query size: "+ rQuery.size());

		start = System.currentTimeMillis();
		MinHeap<Result> result2 = QG.GTS.luceneSearch(rQuery);
		end = System.currentTimeMillis();
//		System.out.println(result2.);
		System.out.println("searching Took: "+(end-start)/1000.0+" Seconds.");
		QG.GTS.closeSearcher();
		
		while( !result1.isEmpty() && !result2.isEmpty())
		{
			Result r1 = (Result) result1.poll();
			Result r2 = (Result) result2.poll();
			System.out.println("Result1 "+ r1);
			System.out.println("Result2 "+ r2);
			System.out.println();
		}
		return false;
	}

	public static void main(String argc[])
	{
		Evaluator ev = new Evaluator();
		ev.evaluate();
	}
}
